package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Pingtaituiguang;
import com.ruoyi.system.service.IPingtaituiguangService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 平台推广Controller
 * 
 * @author ruoyi
 * @date 2024-08-15
 */
@RestController
@RequestMapping("/system/pingtaituiguang")
public class PingtaituiguangController extends BaseController
{
    @Autowired
    private IPingtaituiguangService pingtaituiguangService;

    /**
     * 查询平台推广列表
     */
    @PreAuthorize("@ss.hasPermi('system:pingtaituiguang:list')")
    @GetMapping("/list")
    public TableDataInfo list(Pingtaituiguang pingtaituiguang)
    {
        startPage();
        List<Pingtaituiguang> list = pingtaituiguangService.selectPingtaituiguangList(pingtaituiguang);
        return getDataTable(list);
    }



    /**
     * 导出平台推广列表
     */
    @PreAuthorize("@ss.hasPermi('system:pingtaituiguang:export')")
    @Log(title = "平台推广", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Pingtaituiguang pingtaituiguang)
    {
        List<Pingtaituiguang> list = pingtaituiguangService.selectPingtaituiguangList(pingtaituiguang);
        ExcelUtil<Pingtaituiguang> util = new ExcelUtil<Pingtaituiguang>(Pingtaituiguang.class);
        util.exportExcel(response, list, "平台推广数据");
    }

    /**
     * 获取平台推广详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:pingtaituiguang:query')")
    @GetMapping(value = "/{pttgId}")
    public AjaxResult getInfo(@PathVariable("pttgId") Long pttgId)
    {
        return success(pingtaituiguangService.selectPingtaituiguangByPttgId(pttgId));
    }

    /**
     * 新增平台推广
     */
    @PreAuthorize("@ss.hasPermi('system:pingtaituiguang:add')")
    @Log(title = "平台推广", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Pingtaituiguang pingtaituiguang)
    {
        return toAjax(pingtaituiguangService.insertPingtaituiguang(pingtaituiguang));
    }

    /**
     * 修改平台推广
     */
    @PreAuthorize("@ss.hasPermi('system:pingtaituiguang:edit')")
    @Log(title = "平台推广", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Pingtaituiguang pingtaituiguang)
    {
        return toAjax(pingtaituiguangService.updatePingtaituiguang(pingtaituiguang));
    }

    @PostMapping("/updatelist")
    public AjaxResult updatelist(@RequestBody Pingtaituiguang pingtaituiguang){

        return toAjax(pingtaituiguangService.updatezt(pingtaituiguang));
    }

    /**
     * 删除平台推广
     */
    @PreAuthorize("@ss.hasPermi('system:pingtaituiguang:remove')")
    @Log(title = "平台推广", businessType = BusinessType.DELETE)
	@DeleteMapping("/{pttgIds}")
    public AjaxResult remove(@PathVariable Long[] pttgIds)
    {
        return toAjax(pingtaituiguangService.deletePingtaituiguangByPttgIds(pttgIds));
    }
}
